﻿/* Ree7 Tile Toolkit for Windows Phone
 * Copyright (C) 2011-2014 Pierre BELIN <pierre@ree7.fr>, and project contributors.
 *
 * Distributed under the Microsoft Public License (Ms-PL).
 * See accompanying file License.txt */

using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ree7.TileToolkit
{
	/// <summary>
	/// Provides helper methods to interface CustomTiles with the OS Tile API
	/// </summary>
	public static class CustomTileHelper
	{
		public static StandardTileData GetTileData(CustomTile mediumTile, CustomTile wideTile = null, CustomTile smallTile = null)
		{
			Uri mediumImage = mediumTile.SavePNGToIsolatedStorage();
			Uri largeImage = wideTile == null ? null : wideTile.SavePNGToIsolatedStorage();
			Uri smallImage = smallTile == null ? null : smallTile.SavePNGToIsolatedStorage();

            return ShellTileEx.CreateFlipTileData(" ", null, String.Empty, String.Empty, smallImage, mediumImage, null, largeImage, null, String.Empty);
		}

        public static StandardTileData GetTileData(
			CustomTile mediumFrontTile, CustomTile mediumBackTile, 
			CustomTile wideFrontTile, CustomTile wideBackTile,
			CustomTile smallTile)
		{
			Uri mediumImage = mediumFrontTile.SavePNGToIsolatedStorage();
			Uri mediumBackImage = mediumBackTile == null ? null : mediumBackTile.SavePNGToIsolatedStorage();
			Uri largeImage = wideFrontTile == null ? null : wideFrontTile.SavePNGToIsolatedStorage();
			Uri largeBackImage = wideBackTile == null ? null : wideBackTile.SavePNGToIsolatedStorage();
			Uri smallImage = smallTile == null ? null : smallTile.SavePNGToIsolatedStorage();

            return ShellTileEx.CreateFlipTileData(" ", null, " ", String.Empty, smallImage, mediumImage, mediumBackImage, largeImage, largeBackImage, String.Empty);
		}
	}
}
